// stores/counter.js
import { defineStore } from "pinia";
interface DataType {
  name: string;
  value: string;
}
interface GlobalState {
  activeData: {
    xData: string[];
    yData: string[];
  };
}
export const useDataStore = defineStore("data", {
  state: (): GlobalState => ({
    activeData: {
      xData: [],
      yData: [],
    },
  }),
  actions: {
    setData(data: DataType[]) {
      const xData = [];
      const yData = [];
      for (const item of data) {
        xData.push(item.name);
        yData.push(item.value);
      }
      this.activeData.xData = xData;
      this.activeData.yData = yData;
    },
  },
});
